package com.xzz.trieTree;


/**
 * @author: hhz
 * @create: 2022-01-20 11:13
 * 208. 实现 Trie (前缀树)
 **/
public class Trie {
    // 直接封装 TrieSet
    TrieSet set = new TrieSet();

    public Trie() {

    }
    public void insert(String word) {
        set.add(word);
    }

    public boolean search(String word) {
        return set.contains(word);
    }

    public boolean startsWith(String prefix) {
        return set.hasKeyWithPrefix(prefix);
    }
}
